package com.yc.bank.web;

import com.yc.bank.biz.HelloBiz;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "HelloServlet", value = "/hello.s")
public class HelloServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        final WebApplicationContext ctx =
                WebApplicationContextUtils
                        .getWebApplicationContext(this.getServletContext());

        final HelloBiz helloBiz = ctx.getBean(HelloBiz.class);
        response.getWriter().append("hello ").append(helloBiz.getName());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
